package com.bnuz.vtl.service;

import com.bnuz.vtl.model.Discuss;
import com.bnuz.vtl.repo.DiscussRepo;
import com.bnuz.vtl.repo.PrivateNodeRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiscussService implements BaseService<Discuss, String> {

    @Autowired
    private DiscussRepo discussRepo;
    private PrivateNodeRepo privateNodeRepo;

    @Override
    public Discuss save(Discuss discuss) {
        return null;
    }

    public Discuss save(Discuss discuss, String privateNodeId ) {
        discuss.setPrivateNode(privateNodeRepo.findById(privateNodeId).orElse(null));
        return discuss;
    }

    @Override
    public void deleteById(String discussId) {
        discussRepo.deleteById(discussId);
    }

    @Override
    public List<Discuss> findAll() {
        return discussRepo.findAll();
    }

    @Override
    public Discuss findById(String discussId) {
        return discussRepo.findById(discussId).orElse(null);
    }
}
